// 读取文件
const fs = require('fs');

const path = require('path');


function readFileFn( name ) {
    return new Promise( ( resolve, rejects ) => {
        let mypath = path.join( __dirname, `../assets/${ name }.txt` )
        
        fs.readFile( mypath, ( err, data ) => {
            if( err ) { throw err }
            
            resolve( data.toString() )
        } )

    } )
}

readFileFn( 'abc' ).then( res => {
    console.log(res);
} )

// 或者这样读文件
let fn = async () => {
    let txt = await readFileFn( 'abc' );

    console.log( txt );
}

fn()




